package com.ta.gulimall.ware.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ta.gulimall.common.utils.system.PageUtils;
import com.ta.gulimall.common.utils.system.Query;

import com.ta.gulimall.ware.dao.WareInfoDao;
import com.ta.gulimall.ware.view.entity.WareInfoEntity;
import com.ta.gulimall.ware.service.WareInfoService;


@Service("wareInfoService")
public class WareInfoServiceImpl extends ServiceImpl<WareInfoDao, WareInfoEntity> implements WareInfoService {
    @Override
    public PageUtils pageWares(Map<String, Object> params) {
        String key = (String) params.get("key");
        LambdaQueryWrapper<WareInfoEntity> wrapper = new LambdaQueryWrapper<WareInfoEntity>()
                .eq(StrUtil.isNotBlank(key), WareInfoEntity::getId, key).or().like(StrUtil.isNotBlank(key), WareInfoEntity::getName, key).or()
                .like(StrUtil.isNotBlank(key), WareInfoEntity::getAddress, key).or().like(StrUtil.isNotBlank(key), WareInfoEntity::getAreacode, key);
        IPage<WareInfoEntity> page = this.page(new Query<WareInfoEntity>().getPage(params), wrapper);

        return new PageUtils(page);
    }
}